package com.wuliqing.android.zte.utils;

import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.net.Uri;

public class CallUtil {
	private static Canvas sCanvas = new Canvas();
	private static final Rect sOldBounds = new Rect();

	public static Intent getCallIntent(String number) {
		Uri uri = null;
		if (isUriNumber(number)) {
			uri = Uri.fromParts("sip", number, null);
		} else {
			uri = Uri.fromParts("tel", number, null);
		}
		Intent intent = new Intent(Intent.ACTION_CALL, uri);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		return intent;
	}

	public static boolean isUriNumber(String number) {
		return number != null
				&& (number.contains("@") || number.contains("%40"));
	}

    public static Uri getCallUri(String number) {
        if (isUriNumber(number)) {
             return Uri.fromParts("sip", number, null);
        }
        return Uri.fromParts("tel", number, null);
     }
    
    public static Intent getVideoCallIntent(String number) {
    	Uri uri = getCallUri(number);
        final Intent intent = new Intent(Intent.ACTION_CALL, uri);
//        intent.putExtra("is_default_dialer", true);
        intent.putExtra("android.telecom.extra.START_CALL_WITH_VIDEO_STATE", 3);
        return intent;
    }
}
